#include <stdio.h>
#include "hlog.h"

int hlog(const char *fmt, ...)
{
#ifdef HDEBUG
    int n = 0;
    char buf[4096];
    va_list ap;

    /* Determine required size. */

    va_start(ap, fmt);
    n = vsnprintf(buf, 4096, fmt, ap);
    va_end(ap);

    if (n<4095 && n!=-1) {
            buf[n++] = '\n';
            buf[n++] = 0;
    }
    fprintf(stderr, buf);
    return n;

#else
    return 0;
#endif
}
